function dis=distance(lat1,long1,lat2,long2,avg)
dis=2* earthRadius(lat1) * asin(sqrt(power(sin((toRadians(lat2-lat1))/2),2)+cos(toRadians(lat1))*cos(toRadians(lat2))*power(sin((toRadians(long2-long1))/2),2)))*cos(theta(lat1,long1,lat2,long2)-avg)
end
